<%--
  Created by IntelliJ IDEA.
  User: admin
  Date: 2024-9-22
  Time: 16:25
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%>
<html>
<head>
    <title>新增博客文章</title>
    <style>
        .container {
            width: 500px;
            margin: 100px auto;
            padding: 20px;
            border: 1px solid #ccc;
            border-radius: 5px;
            box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
        }
        .container h2 {
            text-align: center;
            margin-bottom: 20px;
        }
        .form-group {
            margin-bottom: 15px;
        }
        .form-group label {
            display: block;
            margin-bottom: 5px;
        }
        .form-group input[type="text"],
        .form-group input[type="password"] ,
        .form-group select,
        .form-group textarea,
        .form-group input[type="date"]{
            width: 100%;
            padding: 10px;
            border: 1px solid #ddd;
            border-radius: 4px;
            box-sizing: border-box;
        }
        .form-group input[type="submit"] {
            width: 100%;
            padding: 10px;
            border: none;
            border-radius: 4px;
            background-color: #3E93EF;
            color: white;
            cursor: pointer;
        }
        .form-group input[type="submit"]:hover {
            background-color: #4cae4c;
        }
    </style>
</head>
<body>
<div class="container">
    <h2>新增博客文章</h2>
    <form action="ArticleServlet?method=add" method="post">
        <div class="form-group">
            <label>标题:</label>
            <input type="text" name="title" required>
        </div>
        <div class="form-group">
            <label>内容:</label>
            <textarea id="content" name="content" rows="4" cols="50">
            </textarea>
        </div>
        <div class="form-group">
            <label>博客分类:</label>
            <select name="categoryId">
                <c:forEach items="${categoryList}" var="category">
                    <option value="${category.id}"> ${category.name} </option>
                </c:forEach>
            </select>
        </div>

        <div class="form-group">
            <label>作者:</label>
            <select name="userId">
                <c:forEach items="${userList}" var="user">
                    <option value="${user.id}"> ${user.name} </option>
                </c:forEach>
            </select>
        </div>

        <div class="form-group">
            <label>发布时间:</label>
<%--            <input type="text" name="createdTime" >--%>
            <input type="date" name="createdTime"
                   value="<fmt:formatDate value='<%= new java.util.Date() %>' pattern='yyyy-MM-dd' />" />
        </div>
        <div class="form-group">
            <input type="submit" value="提交">
        </div>
    </form>
</div>
</body>
</html>